package p270jp.pxv.android.model;

import android.text.TextUtils;
import java.io.File;
import java.io.Serializable;
import java.util.Locale;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import p270jp.pxv.android.response.PixivResponse;

/* renamed from: jp.pxv.android.model.ProfileEditParameter */
/* loaded from: classes2.dex */
public class ProfileEditParameter implements Serializable {
    public int addressId;
    public String birthDay;
    public Publicity birthDayPublicity;
    public int birthYear;
    public Publicity birthYearPublicity;
    public String comment;
    public String countryCode;
    public boolean deleteProfileImage;
    public Gender gender;
    public Publicity genderPublicity;
    public int jobId;
    public Publicity jobPublicity;
    public String nickName;
    private boolean pawooPublicity;
    public String profileImagePath;
    public Publicity regionPublicity;
    public String twitterAccount;
    public String webpage;

    /* renamed from: jp.pxv.android.model.ProfileEditParameter$Gender */
    /* loaded from: classes2.dex */
    public enum Gender {
        UNKNOWN("unknown"),
        MALE(PixivProfile.GENDER_MALE),
        FEMALE(PixivProfile.GENDER_FEMALE);
        
        private String str;

        Gender(String str) {
            this.str = str;
        }

        public static Gender fromString(String str) {
            Gender[] values = values();
            for (Gender gender : values) {
                if (str.equals(gender.str)) {
                    return gender;
                }
            }
            return UNKNOWN;
        }

        @Override // java.lang.Enum, java.lang.Object
        public String toString() {
            return this.str;
        }
    }

    /* renamed from: jp.pxv.android.model.ProfileEditParameter$Publicity */
    /* loaded from: classes2.dex */
    public enum Publicity {
        PUBLIC("public"),
        PRIVATE("private"),
        MYPIXIV("mypixiv");
        
        private String str;

        Publicity(String str) {
            this.str = str;
        }

        public static Publicity fromString(String str) {
            Publicity[] values = values();
            for (Publicity publicity : values) {
                if (str.equals(publicity.str)) {
                    return publicity;
                }
            }
            return PUBLIC;
        }

        @Override // java.lang.Enum, java.lang.Object
        public String toString() {
            return this.str;
        }
    }

    public ProfileEditParameter() {
        this.profileImagePath = null;
        this.deleteProfileImage = false;
        this.nickName = "";
        this.webpage = "";
        this.twitterAccount = "";
        this.gender = Gender.UNKNOWN;
        this.addressId = 0;
        this.countryCode = "";
        this.birthYear = 0;
        this.birthDay = "";
        this.jobId = 0;
        this.comment = "";
        Publicity publicity = Publicity.PUBLIC;
        this.genderPublicity = publicity;
        this.regionPublicity = publicity;
        this.birthYearPublicity = publicity;
        this.birthDayPublicity = publicity;
        this.jobPublicity = publicity;
        this.pawooPublicity = true;
    }

    @Override // java.lang.Object
    public boolean equals(Object obj) {
        if (!(obj instanceof ProfileEditParameter)) {
            return false;
        }
        ProfileEditParameter profileEditParameter = (ProfileEditParameter) obj;
        String str = this.profileImagePath;
        String str2 = profileEditParameter.profileImagePath;
        if (str == null) {
            if (str != str2) {
                return false;
            }
        } else if (!str.equals(str2)) {
            return false;
        }
        if (this.deleteProfileImage != profileEditParameter.deleteProfileImage || !this.nickName.equals(profileEditParameter.nickName) || !this.webpage.equals(profileEditParameter.webpage) || !this.twitterAccount.equals(profileEditParameter.twitterAccount) || !this.gender.equals(profileEditParameter.gender) || this.addressId != profileEditParameter.addressId || !this.countryCode.equals(profileEditParameter.countryCode) || !this.birthDay.equals(profileEditParameter.birthDay) || this.birthYear != profileEditParameter.birthYear || this.jobId != profileEditParameter.jobId || !this.comment.equals(profileEditParameter.comment) || !this.genderPublicity.equals(profileEditParameter.genderPublicity) || !this.regionPublicity.equals(profileEditParameter.regionPublicity) || !this.birthYearPublicity.equals(profileEditParameter.birthYearPublicity) || !this.birthDayPublicity.equals(profileEditParameter.birthDayPublicity) || !this.jobPublicity.equals(profileEditParameter.jobPublicity) || this.pawooPublicity != profileEditParameter.pawooPublicity) {
            return false;
        }
        return true;
    }

    public RequestBody toRequestBody() {
        MultipartBody.Builder addFormDataPart = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("delete_profile_image", Boolean.toString(this.deleteProfileImage)).addFormDataPart("user_name", this.nickName).addFormDataPart("webpage", this.webpage).addFormDataPart("twitter", this.twitterAccount).addFormDataPart("gender", this.gender.toString()).addFormDataPart("address", Integer.toString(this.addressId)).addFormDataPart("country", this.countryCode).addFormDataPart("job", Integer.toString(this.jobId)).addFormDataPart("comment", this.comment).addFormDataPart("gender_publicity", this.genderPublicity.toString()).addFormDataPart("address_publicity", this.regionPublicity.toString()).addFormDataPart("birth_year_publicity", this.birthYearPublicity.toString()).addFormDataPart("birth_day_publicity", this.birthDayPublicity.toString()).addFormDataPart("job_publicity", this.jobPublicity.toString()).addFormDataPart("pawoo_publicity", Boolean.toString(this.pawooPublicity));
        if (this.profileImagePath != null) {
            File file = new File(this.profileImagePath);
            addFormDataPart.addFormDataPart("profile_image", file.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file));
        }
        if (!TextUtils.isEmpty(this.birthDay) && this.birthYear != 0) {
            addFormDataPart.addFormDataPart("birthday", String.format(Locale.getDefault(), "%4d-%s", Integer.valueOf(this.birthYear), this.birthDay));
        }
        return addFormDataPart.build();
    }

    public ProfileEditParameter(PixivResponse pixivResponse) {
        this.profileImagePath = null;
        this.deleteProfileImage = false;
        String str = "";
        this.nickName = str;
        this.webpage = str;
        this.twitterAccount = str;
        this.gender = Gender.UNKNOWN;
        this.addressId = 0;
        this.countryCode = str;
        this.birthYear = 0;
        this.birthDay = str;
        this.jobId = 0;
        this.comment = str;
        Publicity publicity = Publicity.PUBLIC;
        this.genderPublicity = publicity;
        this.regionPublicity = publicity;
        this.birthYearPublicity = publicity;
        this.birthDayPublicity = publicity;
        this.jobPublicity = publicity;
        this.pawooPublicity = true;
        this.nickName = pixivResponse.user.name;
        PixivProfile pixivProfile = pixivResponse.profile;
        String str2 = pixivProfile.webpage;
        this.webpage = str2 != null ? str2 : str;
        this.twitterAccount = pixivProfile.twitterAccount;
        this.gender = Gender.fromString(pixivProfile.gender);
        PixivProfile pixivProfile2 = pixivResponse.profile;
        this.addressId = pixivProfile2.addressId;
        this.countryCode = pixivProfile2.countryCode;
        this.birthYear = pixivProfile2.birthYear;
        this.birthDay = pixivProfile2.birthDay;
        this.jobId = pixivProfile2.jobId;
        this.comment = pixivResponse.user.comment;
        this.genderPublicity = Publicity.fromString(pixivResponse.profilePublicity.gender);
        this.regionPublicity = Publicity.fromString(pixivResponse.profilePublicity.region);
        this.birthYearPublicity = Publicity.fromString(pixivResponse.profilePublicity.birthYear);
        this.birthDayPublicity = Publicity.fromString(pixivResponse.profilePublicity.birthDay);
        this.jobPublicity = Publicity.fromString(pixivResponse.profilePublicity.job);
        this.pawooPublicity = pixivResponse.profilePublicity.pawoo;
    }
}
